<?php


namespace app\root\controller;


use app\model\Root;
##管理员登录
class RootLogin {
	function index(){
		$input = input('post.');
		if (empty($input['account']) || empty($input['password'])){
			return json(['status'=>false,'msg'=>'账号或密码不能为空']);
		}
		$user = Root::where(['account' => $input['account']])->select();
		if (empty($user['0'])) {
			return json(['status' => false, 'msg' => '账号不存在']);
		}
		if ($user['0']['password'] != $input['password']) {
			return json(['status' => false, 'msg' => '密码错误']);
		}
		$token=JwtUtil::encode($input);
		\session('identity',$user['0']['identity']);
		return json(['status'=>true,'token'=>$token,'user'=>$user]);
	}
}